import Vue from 'vue'

import 'normalize.css/normalize.css' // A modern alternative to CSS resets

import ElementUI from 'element-ui'
import 'element-ui/lib/theme-chalk/index.css'
import locale from 'element-ui/lib/locale/lang/zh-CN' // lang i18n

import '@/styles/index.scss' // global css

import App from './App'
import store from './store'
import router from './router'

// 本地缓存
import Storage from 'vue-ls'
// md5
import md5 from 'js-md5'

import '@/icons' // icon
import '@/permission' // permission control

import * as filters from './filters' // 全局过滤器

/**
 * 使用mock.js
 * 生成环境必须禁止
 */
import './mock'

// 启动参数
import bootstrap from './core/bootstrap'

// 全局权限指令
import './core/directive/action'
import PermissionHelper from '@/utils/helper/permission'
Vue.use(PermissionHelper)

const options = {
  namespace: 'workspace_', // key prefix
  name: 'ls', // name variable Vue.[ls] or this.[$ls],
  storage: 'local' // storage name session, local, memory
}
Vue.use(Storage, options)

Vue.prototype.$md5 = md5

// set ElementUI lang to zh-CN
Vue.use(ElementUI, { locale })

Vue.config.productionTip = false

// 注册过滤器
Object.keys(filters).forEach(key => {
  Vue.filter(key, filters[key])
})

new Vue({
  el: '#app',
  router,
  store,
  created: bootstrap,
  render: h => h(App)
})
